/**
 * Copyright 2007-2010 非也
 * All rights reserved. 
 * 
 * This library is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License v3 as published by the Free Software
 * Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along
 * with this library; if not, see http://www.gnu.org/licenses/lgpl.html.
 *
 */
package org.fireflow2.designer.eclipse.commands.service.human;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.fireflow2.designer.eclipse.commands.service.AbstractServiceCreationWizard;
import org.fireflow2.designer.eclipse.modelwrapper.basic.ServiceDefWrapper;
import org.fireflow2.designer.eclipse.properties.IPropertyValidateListener;
import org.fireflow2.designer.eclipse.properties.service.human.HumanServiceEditPanel;

/**
 * 
 * @author 非也 nychen2000@163.com Fire Workflow 官方网站：www.firesoa.com 或者
 *         www.fireflow.org
 * 
 */
public class ConfigHumanServicePage extends WizardPage  implements
IPropertyValidateListener {
	private static final String TITLE = "配置表单";
	private static final String MESSAGE = "请输入表单相关信息。";

	protected ConfigHumanServicePage(String pageName) {
		super(pageName);
		this.setTitle(TITLE);
		this.setMessage(MESSAGE);
		this.setPageComplete(false);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
	 * .Composite)
	 */
	public void createControl(Composite parent) {
		AbstractServiceCreationWizard humanServiceCreationWizard = (AbstractServiceCreationWizard) this
				.getWizard();
		ServiceDefWrapper svcDef = (ServiceDefWrapper) humanServiceCreationWizard
				.getServiceDefWrapper();
		
		HumanServiceEditPanel humanServiceEditPanel = new HumanServiceEditPanel(svcDef);
		humanServiceEditPanel.addServicePropertyModifyListener(this);
		
		final Composite contentPane = new Composite(parent,SWT.NULL);
		
		Control control = humanServiceEditPanel.createControl(contentPane);
		humanServiceEditPanel.refreshUI();
		this.setControl(control);
	}
	public void onValidateResult(boolean propertyIsOK,String errorMessage,String property,Object newValue,Object oldValue) {
		if (propertyIsOK){
			this.setMessage(MESSAGE);
			this.setErrorMessage(null);
			this.setPageComplete(true);
		}else{
			this.setPageComplete(false);
			this.setMessage(null);
			this.setErrorMessage(errorMessage);
		}
		
	}

}
